package until.jdbc;



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

 
public class DBConnection {
	
	 private static DBConnection instance = new DBConnection();
	    
	    public static DBConnection getInstance(){
	        return instance;
	    }
	
	public Connection getConnection(){
		Connection conn = null;
		
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			try {
				conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.39:1521:ANJIANJU","managedb", "managedb");
			} catch (SQLException e) {
				e.printStackTrace();
			}
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		return conn;
		}
	public void close_tool(Connection conn,PreparedStatement pstmt,ResultSet rs){
		try {if(rs != null){
			rs.close();
			rs = null;}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {if(pstmt != null){
				pstmt.close();
			    pstmt = null;	
			}
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				try {if(conn != null){
					conn.close();
				    conn = null;	
				}
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
	}
	

}
